package com.yanqu.road.server.cmd.activity.jiuzhou;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.jiuzhou.CrossJiuZhouProto;
import com.yanqu.road.pb.activity.jiuzhou.JiuZhouProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.jiuzhou.CrossJiuZhouMgr;
import com.yanqu.road.server.manager.activity.jiuzhou.activity.CrossJiuZhouActivity;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_CROSS_JIU_ZHOU_DEBUG_CODE, desc = "gm指令调试")
public class CrossJiuZhouDebugCmd extends CrossCommand {

    private int activityId;

    private String code;

    private String param;

    private long playerId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CrossJiuZhouProto.JiuZhouDebugReqMsg reqMsg = CrossJiuZhouProto.JiuZhouDebugReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        code = reqMsg.getCode();
        param = reqMsg.getParam();
        playerId = packet.getPlayerId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossJiuZhouActivity activity = CrossJiuZhouMgr.getActivity(activityId);
        if (activity == null) {
            ret = GameErrorCode.E_JIU_ZHOU_ACTIVITY_NOT_EXIST;
            return;
        }
        activity.debugByCmd(playerId, code, param);
    }

    @Override
    public void sendData() {

    }
}
